package com.bdqn.mapper;

import com.bdqn.pojo.SysDept;
import org.apache.ibatis.annotations.*;

import java.util.List;

//科室表
public interface SysDeptMapper {
//    查询所有科室
    @Select("SELECT * FROM sys_dept")
    List<SysDept> getSysDept();
//    根据id查科室
    @Select("SELECT * FROM sys_dept where dept_id=#{deptId}")
    SysDept getSysDeptID(int deptId);
    List<SysDept> getSysDeptFY(@Param("deptId")int deptId);
    List<SysDept> getPage(String deptName, int status);

    @Insert("insert into sys_dept values(null,#{deptName},0,#{deptNumber},#{orderNum},#{deptLeader},#{leaderPhone}," +
            "#{status},now(),now(),#{userName},#{userName})")
    int addDept(String deptName, String deptNumber, String deptLeader, String leaderPhone, int orderNum,
                int status, String userName);

    @Update("update sys_dept set dept_name=#{deptName},dept_number=#{deptNumber},dept_leader=#{deptLeader}," +
            "leader_phone=#{leaderPhone},order_num=#{orderNum},status=#{status},update_by=#{userName} where " +
            "dept_id=#{deptId}")
    int setDept(String deptName, String deptNumber, String deptLeader, String leaderPhone, int orderNum,
                int status, String userName, String deptId);

    @Delete("delete from sys_dept where dept_id=#{deptId}")
    int delDept(String deptId);
}
